# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=shishi
pkgbase=mingw-w64-${_realname}-git
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-git"
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=r3586.6fa08895
pkgrel=1
pkgdesc="a GNU implementation of the Kerberos 5 network security system (mingw-w64)"
arch=('any')
url="https://www.gnu.org/software/shishi/"
license=("GPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-gettext" "wget" "git")
options=('strip' 'staticlibs')
depends=("${MINGW_PACKAGE_PREFIX}-gnutls"
         "${MINGW_PACKAGE_PREFIX}-libidn"
         "${MINGW_PACKAGE_PREFIX}-libgcrypt"
         "${MINGW_PACKAGE_PREFIX}-libgpg-error"
         "${MINGW_PACKAGE_PREFIX}-libtasn1"
        )
source=("${_realname}"::"git+https://git.savannah.gnu.org/git/shishi.git"
        "003-no-shishid.patch"
        "004-fix-download-po.patch"
       )
sha256sums=('SKIP'
            'a5b17bb2840d95d90d591c170ca430726d2cac0e77523cb6e1b84925e8e1cf76'
            '329258931329937824fe37f09666e0b0fc2bd0140a50429e04e4ea40fbd2c411')

pkgver() {
  cd "${srcdir}/${_realname}"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd ${_realname}
  patch -p1 -i ${srcdir}/003-no-shishid.patch
  patch -p1 -i ${srcdir}/004-fix-download-po.patch

  WANT_AUTOMAKE=latest autoreconf -fi
  make update-po
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd build-${MINGW_CHOST}

  ../${_realname}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-static

  make -j1
}

package() {
  cd build-${MINGW_CHOST}
  make DESTDIR="${pkgdir}" install
}
